VERSION ?= 2.9.0

.DEFAULT_GOAL:=help

.PHONY: help customise

help:
	@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n  make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf "  \033[36m%-13s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)

build: generate customise

generate:
	docker run --rm -v `pwd`:/local -u `id -u ${USER}`:`id -g ${USER}` \
		openapitools/openapi-generator-cli:v4.3.1 generate \
		--strict-spec=true \
		--additional-properties enumClassPrefix=true \
		--additional-properties packageName=api \
		--additional-properties packageVersion=$(VERSION) \
		-i /local/openapi.yaml -g go -o /local/autogenerated
	rm -f autogenerated/go.mod autogenerated/go.sum

customise:
	sed -i 's/\[]map/map/ig' autogenerated/*.go

clean:
	rm -r autogenerated
